Regarding the search engine, there are two distinct methods of development and deployment to look at.
a) development is performed on a server (e.g. localhost) and deployment is made to a live server, because the live server contains an up to date copy of the web-site to be searched the search index is built against the live server (by importing the current live site), as a result the search result URLs will be correct and the only issue regarding deployment is that of the IndexDirectoy property (see 1. below).
b) development is performed on a server (e.g. localhost) and deployment is made to a live server, because the live server DOES NOT contain an up to date copy of the web-site to be searched the search index is built against the development server, as a result the search result URLs will be incorrect when the index files are deployed to the live server, so they must be mapped from development to deployment (see 1. and 2. below).
1. How to configure the IndexDirectory path
The IndexDirectory property is a file path on the server where the control can read the index files. The property in SearchResult can be overridden by values appearing in the web.config, under the name "Keyoti- SearchEngine-IndexDirectory". This means that the web.config for the deployment server can contain information specific to it, for example;
<!-- Web.Config Configuration File --> <configuration> <system.web> <customErrors mode="Off"/> </system.web> <appSettings> <add key="Keyoti-SearchEngine-IndexDirectory" value="d:\web\app1\Indexes"/> <add key="Keyoti-SearchEngine-LicenseKey" value="257375237C7B79.....53"/> </appSettings>
If these settings are present in the web.config on the production server for example, it will read the index from "d:\web\app1\Indexes" regardless of the settings in the IndexDirectory property in the code. This means that it is safe and convenient to keep a development machine specific IndexDirectory set in code.
Alternatively, with .NET 2 up, it is possible to specify the IndexDirectory as a relative URL, eg. ~/IndexDirectory, if the IndexDirectory is located under the application root. Provided the IndexDirectory is in the same position under development and on the server, there should be no changes necessary.
2. How to map development machine URLs to deployment machine URLs
When an index is built against a machine, for example "localhost" the document URLs stored in the index will be specific to that machine and since those URLs are linked to result items, they will be invalid. Eg. if an index is built on localhost the document URLs will likely be "http://localhost/app1/default.aspx" etc (this is actually dependent on the URLs entered in the web-site spider and indexer list - it is totally possible to index a currently live site from localhost, in which case this part is unnecessary).
Mapping from the URLs gained from the development server (eg localhost) to the deployment server is simple, the SearchResult control has a property "From URIPattern" which is used to specify the URL part specific to the development server, and a property "ToURIPattern" which is used to specify the URL part specific to the deployment server, at run-time the search result URLs are mapped according to these two properties.
Eg 1. A developer builds a web-site on http://localhost/internalApp/ and builds the search index - the search works fine on localhost, however when moving the app. to the live server the search results are linked to localhost. To correct this the developer maps the localhost URLs to the real server's, by setting:
FromURIPattern = "localhost/internalApp"
ToURIPattern = "ourcompanysinternalserver"This causes URLs like
http://localhost/internalApp/products/product1.aspx
to be mapped to
http://ourcompanysinternalserver/products/product1.aspx
Eg 2. A developer builds a web-site on http://staging.ourdomain.com/ and builds the search index - the search works fine on the staging server, however when moving the app. to the live server the search results are linked to staging.ourdomain.com. To correct this the developer maps the staging.ourdomain.com URLs to the real server's, by setting:
FromURIPattern = "staging.ourdomain.com"
ToURIPattern = "www.ourdomain.com"This causes URLs like
http://staging.ourdomain.com/default.aspx
to be mapped to
http://www.ourdomain.com/default.aspx
The properties FromURIPattern and ToURIPattern can also be overridden in the web.config, by adding "Keyoti-SearchEngine-FromURIPattern" and "Keyoti-SearchEngine-ToURIPattern" in the same manner as the IndexDirectory property.